{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f272e2db",
   "metadata": {},
   "source": [
    "________________\n",
    "\n",
    "* 2022/10/10/ week07\n",
    "* Python学习记录\n",
    "\n",
    "_________________"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d865c4ec",
   "metadata": {},
   "source": [
    "# 本周知识点\n",
    "\n",
    "* 1. 有序的数字结构----字符串（str）\n",
    "* 2. 有序的数据结构----列表（list）"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d9080575",
   "metadata": {},
   "source": [
    "## 1. 字符串（string）\n",
    "> 1. 关于字符串的基本内容\n",
    "> 2. 关于字符串的方法及函数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "87fec683",
   "metadata": {},
   "source": [
    "### 1.1 关于字符串的基本内容"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9b017d58",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'spam eggs'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'spam eggs'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9c82d895",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type('spam eggs'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "bd50a3dd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(type(\"spam eggs\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e575f4fc",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (3578565646.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [4]\u001b[1;36m\u001b[0m\n\u001b[1;33m    'doesn't'\u001b[0m\n\u001b[1;37m           ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "'doesn't'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "64edc539",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 以上解决方案\n",
    "\"doesn't\"\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "78150b8b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'doesn\\'t'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "d41adbba",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 三引号：保留字符串信息的格式信息,保留完整的数据信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "127d05dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\"doesn't\""
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''doesn't'''"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "4554bef3",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "EOL while scanning string literal (611186233.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [9]\u001b[1;36m\u001b[0m\n\u001b[1;33m    \"使用三重引号的字符串可以跨越多行 —— 其中所有的空白字符都将包含在该字符串字面值中。\u001b[0m\n\u001b[1;37m                                                ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m EOL while scanning string literal\n"
     ]
    }
   ],
   "source": [
    "\"使用三重引号的字符串可以跨越多行 —— 其中所有的空白字符都将包含在该字符串字面值中。\n",
    "\n",
    "作为单一表达式组成部分，之间只由空格分隔的多个字符串字面值会被隐式地转换为单个字符串字面值。 也就是说\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "34879f01",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'使用三重引号的字符串可以跨越多行 —— 其中所有的空白字符都将包含在该字符串字面值中。作为单一表达式组成部分，之间只由空格分隔的多个字符串字面值会被隐式地转换为单个字符串字面值。 也就是说'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"使用三重引号的字符串可以跨越多行 —— 其中所有的空白字符都将包含在该字符串字面值中。作为单一表达式组成部分，之间只由空格分隔的多个字符串字面值会被隐式地转换为单个字符串字面值。 也就是说\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "21a06926",
   "metadata": {},
   "source": [
    "### 1.2 关于字符串的方法及函数\n",
    "\n",
    "> 1. 字符串是可以拼接的 （字符串的运算）,用 + 进行字符串之间的拼接\n",
    "> 2. 字符串是有顺序的，从第一个字符开始，从0依次往后，有长度，可以用len()方法检查字符串长度\n",
    "> 3. 字符串的取值：\n",
    ">> 1. 取单个值 ：从左往右（正数，第一个值是0），从右往左（负数，第一个值是-1）\n",
    ">> 2. 取多个值 ：切片的方法，两个值作为取值的区间\n",
    "> 4. 字符串的方法及函数\n",
    ">> 1. in 查询成员是否存在\n",
    ">> 2. str.count()查询数量\n",
    ">> 3. str.isdigit()判断字符串是否是数字\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "ae93ef61",
   "metadata": {},
   "outputs": [],
   "source": [
    "nev_name = [\"小明\",\"小红\",\"张杰\",\"李华\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "2264c20b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州南方学院团委欢迎小明\n",
      "广州南方学院团委欢迎小红\n",
      "广州南方学院团委欢迎张杰\n",
      "广州南方学院团委欢迎李华\n"
     ]
    }
   ],
   "source": [
    "for i in nev_name:\n",
    "    print(\"广州南方学院团委欢迎\"+i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "ad2c6d4c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院团委欢迎小明'"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"广州南方学院团委欢迎\"+\"小明\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "6509da6c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广州南方学院团委欢迎小明'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text = '广州南方学院团委欢迎小明'\n",
    "text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "da58d987",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "b98bac62",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'州'"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "442cb04e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'南'"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "e3815bda",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "string index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [21]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mtext\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m12\u001b[39;49m\u001b[43m]\u001b[49m\n",
      "\u001b[1;31mIndexError\u001b[0m: string index out of range"
     ]
    }
   ],
   "source": [
    "text[12]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "c8f002cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "12"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "6f599b5c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'团委'"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text[6]+text[7]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "ea81e036",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'团委'"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用切片的方法进行多个值取值\n",
    "text[6:8]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fb386992",
   "metadata": {},
   "source": [
    "* in 查询成员"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "e7c8010d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'广州'in text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "14343c88",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'北京'in text"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b3a70b6a",
   "metadata": {},
   "source": [
    "* str.count()查询数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "c2cd7368",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text.count('广州')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "2d0c325b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text.count('北京')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "282ae0e9",
   "metadata": {},
   "source": [
    "* str.isdigit()判断字符串是否是数字"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "423eebd8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19 <class 'int'>\n",
      "19 <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "age_li = 19\n",
    "age_wang = '19'\n",
    "print(age_li,type(age_li))\n",
    "print(age_wang,type(age_wang))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "c10c3f6f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "age_wang.isdigit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "0cb3b375",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "text.isdigit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "a9af67ed",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "unsupported operand type(s) for /: 'str' and 'int'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [41]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m19\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[38;5;241;43m2\u001b[39;49m\n",
      "\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for /: 'str' and 'int'"
     ]
    }
   ],
   "source": [
    "'19'/2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4d47663e",
   "metadata": {},
   "source": [
    "## 2. 有序的数据结构——列表（list）\n",
    "\n",
    "* Python 支持多种 复合 数据类型，可将不同值组合在一起。最常用的 列表 ，是用方括号标注，逗号分隔的一组值。列表 可以包含不同类型的元素，但一般情况下，各个元素的类型相同。\n",
    "\n",
    "> 1.列表的基本运算法则（参考：有序的数据结构的运算法则列表）\n",
    "> 2. 列表的一般方法（要求：全部掌握，并且做总结在课后笔记中）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "9e0722ff",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 思考：假设有这样一个场景，我要录入/存放一个班的同学的信息（名单信息），用字符串存放是否可行？如何取值呢\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "7933dedb",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 字符串存放\n",
    "网二_name = \"李华,小明,李晓华,小红\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "de888497",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李华'"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 字符串取值,比较麻烦\n",
    "网二_name[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "f6a944fa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李晓华'"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name[6:9]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "9623a627",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李晓华,'"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name[6:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d71e1867",
   "metadata": {},
   "outputs": [],
   "source": [
    "* 对比字符串和列表\n",
    "> 1. 字符串是按照字符进行数据取值\n",
    "> 2. 列表是按照元素进行数据取值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "09b34da3",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_name_list = [\"李华\",\"小明\",\"李晓华\",\"小红\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "efbb4fb1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(网二_name_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "9a0c5d23",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'李华'"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "950af7bb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['李华', '小明']"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name_list[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "d1fb2c6a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['李晓华', '小红']"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_name_list[-2:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "cea0e2ae",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_age_list = [19,18,19,20]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "049f87cd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19"
      ]
     },
     "execution_count": 60,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_age_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "0188cd2e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[19,\n",
       " 18,\n",
       " 19,\n",
       " 20,\n",
       " 19,\n",
       " 18,\n",
       " 19,\n",
       " 20,\n",
       " 19,\n",
       " 18,\n",
       " 19,\n",
       " 20,\n",
       " 19,\n",
       " 18,\n",
       " 19,\n",
       " 20,\n",
       " 19,\n",
       " 18,\n",
       " 19,\n",
       " 20]"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_age_list*5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "b2cf5c64",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_age_list.count(19)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "581dc597",
   "metadata": {},
   "source": [
    "## 2.2 [列表的方法](https://docs.python.org/zh-cn/3/library/stdtypes.html#sequence-types-list-tuple-range)\n",
    "\n",
    "> 1. 增加\n",
    "> 2. 删除\n",
    "> 3. 修改\n",
    "> 4. 查询in, count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "81a1e600",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = [\"Mike\",\"Marry\",\"Jan\",\"Jack\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5659884c",
   "metadata": {},
   "source": [
    "* 学习方法\n",
    "> 1. listname.Tab键 查看所有方法名称\n",
    "> 2. help(listname.function)查看其中一个方法的具体操作方法\n",
    "\n",
    "课后练习（做一个表格，总结列表的方法）：\n",
    "\n",
    "\n",
    "| Syntax      | Description | example | 备注  \n",
    "| ----------- | ----------- | ----------- | ----------- |\n",
    "| Header      | Title       |\n",
    "| Paragraph   | Text        |"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "edb95dfe",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "e77ae49b",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(\"linhan\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "c5d4dd09",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'Marry', 'Jan', 'Jack', 'linhan']"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "a2fe36ef",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function insert:\n",
      "\n",
      "insert(index, object, /) method of builtins.list instance\n",
      "    Insert object before index.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.insert)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "95578bb1",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.insert(1,\"Alex\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "8f9647c9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Mike', 'Alex', 'Marry', 'Jan', 'Jack', 'linhan']"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "36871692",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
